#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTreeWidget>
#include "sql.h"
#include "ebookpath.h"
#include "dlgaddlabel.h"
#include "dlgaddintroduction.h"
#include "dlgmodifyinfo.h"
#include "batchmodify.h"
#include "importfromcsv.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    QString getTableLineStr(int row);

    void tabelWidgetShow(QList<EbookInfo> bookInfoList, int rowNum);

    void treeWidgetParentNodeShow();

    void treeWidgetShow();

    void openFileDir(QString filepath);

    QList<EbookInfo> getCurrentTableData();

    void clearData();

private slots:
    void clearAllData();

    void clearNotExistData();

    void reloadData();

    void showData();

    void tableWidgetSelectRow(int row,int col);

    void tableCellDoubleClickOperation(int row, int col);

    void tabelWidgetTooltip(QModelIndex index);

    void treeSearchShow(QTreeWidgetItem* treeItem, int n);

    void on_ptnAddLabel_clicked();

    void on_ptnAddIntroduction_clicked();

    void updateBookLabel(QStringList labelList);

    void updateBookIntro(QString strIntro);

    void bookInfoShow(EbookInfo bookInfo);

    void on_tableWidget_customContextMenuRequested(const QPoint &pos);

    void tableWidgetMenuRequestedOpenFile(int row);

    void tableWidgetMenuRequestedOpenFilePath(int row);

    void tableWidgetMenuRequestedCopy(int row, int col);

    void tableWidgetMenuRequestedCopyLine(int row);

    void tableWidgetMenuRequestedModifyInfo(int row);

    void modifyConfirmedShow(EbookInfo bookInfo);

    void on_ptnOpenFile_clicked();

    void on_ptnOpenFilePath_clicked();

    void on_ptnModifyBookInfo_clicked();

    void on_ptnSearch_clicked();

    void on_ptnExport_clicked();

    void on_ptnImport_clicked();

    void on_ptnBatchModify_clicked();

    void getModifyTableData(QList<EbookInfo> resBookInfoList, int rowNum);

    void getImportData(QList<EbookInfo> importBookinfoList);

private:
    Ui::MainWindow *ui;
    Sql *m_ptrSql;
    EbookPath m_eBookPath;
    EbookInfo m_bookInfo;
    DlgAddLabel m_addLabel;
    DlgAddIntroduction m_addIntro;
    DlgModifyInfo m_modifyInfo;
    BatchModify m_batchModify;
    ImportFromcsv m_importFromcsv;

    QTreeWidgetItem *pBookType;
    QTreeWidgetItem *pBookDir;
    QTreeWidgetItem *pBookLabel;

    QStringList tablewidgetTitle;
    int tablewidgetColumnCount;
    QString m_filepath;
    QMap<QString, QString> m_tableInfoMap;
    bool m_isImportFromcsv = false;
};
#endif // MAINWINDOW_H
